var SysUserLoginLogDatagrid = new HgUi.Datagrid("SysUserLoginLog_datagrid");
SysUserLoginLogDatagrid.toolbar = $("#SysUserLoginLog_toolbar");
SysUserLoginLogDatagrid.options.isShowContextMenu = true;
SysUserLoginLogDatagrid.options.tipCells 
	= ["accountId","sysAccount.loginName","sysAccount.sysUser.userName","loginType","operCode","operName","engName",
	   "content","operRes","exceptionName","isAccumulateLoginTimes","operIp","reqUri","reqType","reqMethod",
	   "browserType","reqUserAgent","loginLocation","crtTime"];
SysUserLoginLogDatagrid.options.onSelect = function(index,row) {
    if (row && row.dictGroupId){
        SysUserLoginLogDatagrid.selectedRow = row;
    }
};
SysUserLoginLogDatagrid.options.onLoadSuccess = function(data) {
    SysUserLoginLogDatagrid.grid.datagrid("selectRow",0);
};
SysUserLoginLogDatagrid.reload = function() {
	SysUserLoginLogDatagrid.grid.datagrid("reload");
};
SysUserLoginLogDatagrid.init();
SysUserLoginLogDatagrid.bindDefaultToolbarEvent();

//登录方式combobox
SysUserLoginLogDatagrid.toolbar.find("#loginType").combobox({  
	panelHeight:'auto',
	editable:false,
	textField:'text',
	valueField:'value',    
	prompt: '---请选择---',
	data:HgUtil.getDictComboboxData('loginMode')
});
//操作结果combobox
SysUserLoginLogDatagrid.toolbar.find("#operRes").combobox({  
	panelHeight:'auto',
	editable:false,
	textField:'text',
	valueField:'value',    
	prompt: '---请选择---',
	data:HgUtil.getDictComboboxData('LOG_RESULT')
});
//请求类型combobox
SysUserLoginLogDatagrid.toolbar.find("#reqType").combobox({  
	panelHeight:'auto',
	editable:false,
	textField:'text',
	valueField:'value',    
	prompt: '---请选择---',
	data:HgUtil.getDictComboboxData('requestType')
});

//查询------------------------------------------------------------------------------------------------------
SysUserLoginLogDatagrid.toolbar.find("[tag=submit]").click(function(){
	var searchData = {};
	searchData["loginName"] =  $.trim(SysUserLoginLogDatagrid.toolbar.find("[name=loginName]").val());
	searchData["loginType"] =  $.trim(SysUserLoginLogDatagrid.toolbar.find("[name=loginType]").val());
	searchData["reqUri"] =  $.trim(SysUserLoginLogDatagrid.toolbar.find("[name=reqUri]").val());
	searchData["reqType"] =  $.trim(SysUserLoginLogDatagrid.toolbar.find("[name=reqType]").val());
	searchData["reqMethod"] =  $.trim(SysUserLoginLogDatagrid.toolbar.find("[name=reqMethod]").val());
	
	searchData["operIpStr"] =  $.trim(SysUserLoginLogDatagrid.toolbar.find("[name=operIp]").val());
	searchData["operRes"] =  $.trim(SysUserLoginLogDatagrid.toolbar.find("[name=operRes]").val());
	searchData["content"] =  $.trim(SysUserLoginLogDatagrid.toolbar.find("[name=content]").val());
	
	searchData["startTimeStr"] =  $.trim(SysUserLoginLogDatagrid.toolbar.find("[name=startTime]").val());
	searchData["endTimeStr"] =  $.trim(SysUserLoginLogDatagrid.toolbar.find("[name=endTime]").val());
	if(searchData["startTimeStr"]){
		searchData["startTimeStr"] = searchData["startTimeStr"] + " 00:00:00";
	}
	if(searchData["endTimeStr"]){
		searchData["endTimeStr"] = searchData["endTimeStr"] + " 24:00:00";
	}
	
	SysUserLoginLogDatagrid.grid.datagrid('load',searchData);
});

// 清空查询---------------------------------------------------------------------------------------------------
SysUserLoginLogDatagrid.toolbar.find("[tag=clear]").click(function() {
    $("#SysUserLoginLogSearchForm").form("clear");
	//清空后combobox选中第一条“请选择”数据
    SysUserLoginLogDatagrid.toolbar.find("#operRes").combobox("setValue",'');
    SysUserLoginLogDatagrid.toolbar.find("#reqType").combobox("setValue",'');
    SysUserLoginLogDatagrid.toolbar.find("#loginType").combobox("setValue",''); 
	SysUserLoginLogDatagrid.grid.datagrid("load", {});
});
